home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Add-Ons / After Dark / Sort / PixelUtils 1.0.p < prev    next >
Encoding:
Text File  |  1994-11-23  |  15.9 KB  |  553 lines  |  [TEXT/PJMM]

  1. unit PixelUtils;
  2. {Written by Scott Lindhurst, lindhurs@math.wisc.edu, in the Fall of 1993, revised Nov. 1994.}
  3.  
  4. interface
  5.     uses
  6.         GraphicsModuleTypes;
  7.     type
  8.         PixelRec = record
  9.                 sortValue: longint;
  10.                 memoryValue: longint;    {private to Get and SetPixel; the value to put directly in memory.}
  11.             end;
  12.  
  13.     var
  14. {Pixel numbering starts with number 1 in the upper left corner, down to ScreenPixels}
  15. {in the lower right corner. Only the main screen is considered.}
  16.         ScreenPixels: longint;
  17.         ScreenDepth: integer;
  18.         gHas32BitQD: boolean;
  19.  
  20.     procedure InitPixelUtils (drawRect: Rect;
  21.                                     depth: integer;
  22.                                     colorQDAvail: boolean;
  23.                                     useDirectPixels: integer);
  24.  
  25.     procedure EraseOutsideDrawArea (blankRgn: rgnHandle;
  26.                                     params: GMParamBlockPtr);
  27.  
  28.     procedure LockForDrawing;
  29.  
  30.     procedure UnlockForDrawing;
  31.  
  32.     procedure RandomFillScreen;
  33. {Randomly fill the screen. Assumes that LockForDrawing has been called.}
  34.  
  35.  
  36.     function MyGetPixel (pixelNum: longint): PixelRec;
  37. {Get the value of the pixelNum pixel on the screen.}
  38.  
  39.     procedure MySetPixel (pixelNum: longint;
  40.                                     pixelValue: pixelRec);
  41. {Set the pixel at pixelNum to value.}
  42.  
  43.     procedure SwapPixels (first, second: longint);
  44. {Swap the pixels in positions first and second}
  45.     procedure SortPair (first, second: longint);
  46. {Sort the pair of pixels at positions first and second so the pixel at first is less.}
  47.     procedure SortThree (first, second, third: longint);
  48. {Sort the three pixels at first, second, and third, with first being the least.}
  49.  
  50.  
  51. implementation
  52.  
  53.     uses
  54.         QDOffscreen, Picker;
  55.  
  56.     type
  57.         SixBytes = packed array[1..6] of Byte;    {Used in converting RGBColor to a longint}
  58.         FourBytes = packed array[1..4] of Byte;
  59.         BitMapPtr = ^BitMap;
  60.         bytePtr = ^signedByte;
  61.         wordPtr = ^integer;
  62.         longPtr = ^longint;
  63.  
  64. {Method for drawing pixels: Direct to screen in old QD, color QD, 32 Bit QD, or using QD calls.}
  65.         pixMethodType = (DirectMono, DirectColor, Direct32Bit, ColorQuickDraw, MonoQuickDraw);
  66.  
  67.  
  68.     var
  69.         ScreenWidth, ScreenHeight, ScreenLeft, ScreenTop: integer;    {Set by Initialize procedure.}
  70.         PixMethod: pixMethodType;
  71.         drawBitMap: BitMap;        {The bitmap to draw directly into, if no color QD}
  72.         drawPixMap: PixMapHandle;    {The PixMap to draw directly into, if color QD}
  73.         pmBaseAddr: longint;    {Base address of the currently used pixMap for direct drawing}
  74.         swapMode: boolean;    {Below are set up by Lock/Unlock forDrawing}
  75.         mode: signedByte;        {and generally used by Get/SetColorPixel}
  76.         pixState: GWorldFlags;
  77.         rowBytes: longint;
  78.         pixelDepth: integer;
  79.  
  80.  
  81.     procedure InitPixelUtils (drawRect: Rect;
  82.                                     depth: integer;
  83.                                     colorQDAvail: boolean;
  84.                                     useDirectPixels: integer);
  85. {Set ScreenWidth, Height, Pixels, depth, left, and top corner.}
  86. {Draws directly to screen if useDirectPixels is 1.}
  87.         var
  88.             GestaltResult: longint;
  89.             Has32Bit: boolean;
  90.             myPort: GrafPtr;
  91.  
  92.     begin
  93.         ScreenLeft := drawRect.left;
  94.         ScreenTop := drawRect.top;
  95.         ScreenWidth := drawRect.right - ScreenLeft;
  96.         ScreenHeight := drawRect.bottom - ScreenTop;
  97.         ScreenPixels := longint(ScreenWidth) * ScreenHeight;
  98.         ScreenDepth := depth;
  99.         GetPort(myPort);
  100.  
  101.         if (Gestalt(gestaltQuickDrawVersion, GestaltResult) = noErr) & (GestaltResult >= gestalt32BitQD) then
  102.             Has32Bit := true
  103.         else
  104.             Has32Bit := false;
  105.         if colorQDAvail then
  106.             begin
  107.                 drawPixMap := CGrafPtr(myPort)^.portPixMap;
  108.                 if useDirectPixels = 0 then    {Don’t draw directly}
  109.                     pixMethod := ColorQuickDraw
  110.                 else    {Direct drawing}
  111.                     begin
  112.                         ScreenTop := ScreenTop - drawPixMap^^.bounds.top;    {direct: we need global coords}
  113.                         ScreenLeft := ScreenLeft - drawPixMap^^.bounds.left;
  114.                         if Has32Bit then
  115.                             pixMethod := Direct32Bit    {Direct to screen under 32Bit QD}
  116.                         else
  117.                             pixMethod := DirectColor;    {Direct to screen drawing on colorQD, no 32Bit QD}
  118.                     end
  119.             end
  120.         else    {only Monochrome QuickDraw}
  121.             begin
  122.                 drawBitMap := myPort^.portBits;
  123.                 if useDirectPixels = 1 then
  124.                     begin
  125.                         ScreenTop := ScreenTop - drawBitMap.bounds.top;
  126.                         ScreenLeft := ScreenLeft - drawBitMap.bounds.left;
  127.                         pixMethod := DirectMono;        {Direct to screen drawing on a non-colorQD machine}
  128.                     end
  129.                 else
  130.                     pixMethod := MonoQuickDraw;
  131.             end;
  132.     end;    {procedure InitPixelUtils}
  133.  
  134.  
  135.     procedure EraseOutsideDrawArea (blankRgn: rgnHandle;
  136.                                     params: GMParamBlockPtr);
  137. {Erase stuff in the blankRgn, but outside the area to draw in.}
  138. {The drawing area must have been set up by InitPixelUtils previously.}
  139.         var
  140.             drawRgn: rgnHandle;
  141.             drawRect: Rect;
  142.     begin
  143.         SetRect(drawRect, ScreenLeft, ScreenTop, ScreenLeft + ScreenWidth, ScreenTop + ScreenHeight);
  144.         if not (pixMethod in [ColorQuickDraw, MonoQuickDraw]) then
  145.             offsetRect(drawRect, -ScreenLeft, -ScreenTop);
  146.         drawRgn := NewRgn;
  147.         RectRgn(drawRgn, drawRect);
  148.         DiffRgn(blankRgn, drawRgn, drawRgn);
  149.         FillRgn(drawRgn, params^.qdGlobalsCopy^.qdBlack);
  150.         DisposeRgn(drawRgn);
  151.     end;    {procedure EraseOutsideDrawArea}
  152.  
  153.  
  154.     procedure LockForDrawing;
  155. {Call this just before drawing. Then draw using only MyGetPixel and MySetPixel;}
  156. {don’t call other drawing routines. Call UnlockForDrawing before exiting.}
  157. {It will draw to the bit or pixMap that was selected by the initialize procedure.}
  158.         var
  159.             ignore: boolean;
  160.     begin
  161.         case pixMethod of
  162.             DirectColor, Direct32Bit: 
  163.                 begin
  164.                     rowBytes := BitAnd(drawPixMap^^.rowBytes, $1FFF);    {Strip flags}
  165.                     pixelDepth := drawPixMap^^.pixelSize;
  166.  
  167.                     if pixMethod = Direct32Bit then
  168.                         begin
  169.                             mode := true32b;
  170.                             swapMode := PixMap32Bit(drawPixMap);
  171.                             pixState := GetPixelsState(drawPixMap);
  172.                             ignore := LockPixels(drawPixMap);
  173.                             pmBaseAddr := longint(GetPixBaseAddr(drawPixMap));
  174.                             if swapMode then
  175.                                 SwapMMUMode(mode);
  176.                         end;
  177.                 end;    {DirectColor or Direct32Bit}
  178.             otherwise
  179.                 ;
  180.         end;    {case pixMethod of}
  181.     end;    {procedure LockForDrawing}
  182.  
  183.  
  184.     procedure UnlockForDrawing;
  185.     begin
  186.         if pixMethod = Direct32Bit then
  187.             begin
  188.                 if swapMode then
  189.                     SwapMMUMode(mode);
  190.                 SetPixelsState(drawPixMap, pixState);
  191.             end;
  192.     end;    {procedure UnlockForDrawing}
  193.  
  194.  
  195.     procedure SetBWPixel (x, y: integer;
  196.                                     value: longint;
  197.                                     var theBitMap: BitMap);
  198. {Set a pixel on a monochrome, non-colorQD display.}
  199.         var
  200.             mask, shiftBits: integer;
  201.             thePixel: longint;
  202.  
  203.     begin
  204.         thePixel := longint(theBitMap.baseAddr);
  205.         thePixel := thePixel + (theBitMap.rowBytes * longint(y)) + (x div 8);
  206.         shiftBits := 7 - (x mod 8);
  207.         mask := BSL(1, shiftBits);
  208. {$R-}
  209.         bytePtr(thePixel)^ := BitAnd(bytePtr(thePixel)^, BitNot(mask));
  210.         bytePtr(thePixel)^ := BitOr(bytePtr(thePixel)^, BSL(value, shiftBits));
  211. {$R+}
  212.     end;    {procedure SetBWPixel}
  213.  
  214.  
  215.     function GetBWPixel (x, y: integer;
  216.                                     var theBitMap: BitMap): longint;
  217. {Get a pixel on a monochrome, non-colorQD display.}
  218.         var
  219.             mask, shiftBits: integer;
  220.             thePixel: longint;
  221.  
  222.     begin
  223.         thePixel := longint(theBitMap.baseAddr);
  224.         thePixel := thePixel + (theBitMap.rowBytes * longint(y)) + BSR(x, 3);    {that’s x div 8}
  225.         shiftBits := 7 - BitAnd(x, $7);    {that’s x mod 8}
  226.         mask := BSL(1, shiftBits);
  227.         if BitAnd(bytePtr(thePixel)^, mask) <> 0 then
  228.             GetBWPixel := 1
  229.         else
  230.             GetBWPixel := 0;
  231.     end;    {function GetBWPixel}
  232.  
  233.  
  234.     procedure SetColorPixel (x, y: integer;
  235.                                     value: longint);
  236. {Set a pixel on a color display.}
  237.         var
  238.             mask, shiftBits: integer;
  239.             thePixel: longint;
  240.  
  241.     begin
  242.         thePixel := pmBaseAddr;
  243.         case pixelDepth of
  244.             1, 2, 4: 
  245.                 begin
  246.                     thePixel := thePixel + (rowBytes * longint(y)) + BSR(pixelDepth * x, 3);{BSR is div 8}
  247.                     shiftBits := (8 - pixelDepth) - BitAnd(x * pixelDepth, $7);    {BitAnd instead of mod 8}
  248.                     mask := BSL(BSL(1, pixelDepth) - 1, shiftBits);
  249.                     bytePtr(thePixel)^ := BitAnd(bytePtr(thePixel)^, BitNot(mask));
  250.                     bytePtr(thePixel)^ := BitOr(bytePtr(thePixel)^, BSL(value, shiftBits));
  251.                 end;
  252.  
  253.             8: 
  254.                 begin
  255.                     thePixel := thePixel + (rowBytes * longint(y) + x);
  256.                     bytePtr(thePixel)^ := value;
  257.                 end;
  258.  
  259.             16: 
  260.                 begin
  261.                     thePixel := thePixel + (rowBytes * longint(y)) + (2 * x);
  262.                     wordPtr(thePixel)^ := value;
  263.                 end;
  264.  
  265.             32: 
  266.                 begin
  267.                     thePixel := thePixel + (rowBytes * longint(y)) + (4 * x);
  268.                     longPtr(thePixel)^ := value;
  269.                 end;
  270.         end;    {case depth of}
  271.     end;    {procedure SetPixel}
  272.  
  273.  
  274.  
  275.     function GetColorPixel (x, y: integer): longint;
  276. {Get a pixel from a color display. Returns the actual value in memory, not an RGBcolor.}
  277.         var
  278.             mask, shiftBits: integer;
  279.             thePixel: longint;
  280.  
  281.     begin
  282.         thePixel := pmBaseAddr;
  283.         case pixelDepth of
  284.             1, 2, 4: 
  285.                 begin
  286.                     thePixel := thePixel + (rowBytes * longint(y)) + BSR(pixelDepth * x, 3);{BSR is div 8}
  287.                     shiftBits := (8 - pixelDepth) - BitAnd(x * pixelDepth, $7);    {BitAnd instead of mod 8}
  288.                     mask := BSL(BSL(1, pixelDepth) - 1, shiftBits);
  289.                     GetColorPixel := BSR(BitAnd(bytePtr(thePixel)^, mask), shiftBits);
  290.                 end;
  291.  
  292.             8: 
  293.                 begin
  294.                     thePixel := thePixel + (rowBytes * longint(y) + x);
  295.                     GetColorPixel := bytePtr(thePixel)^;
  296.                 end;
  297.  
  298.             16: 
  299.                 begin
  300.                     thePixel := thePixel + (rowBytes * longint(y)) + (2 * x);
  301.                     GetColorPixel := wordPtr(thePixel)^;
  302.                 end;
  303.  
  304.             32: 
  305.                 begin
  306.                     thePixel := thePixel + (rowBytes * longint(y)) + (4 * x);
  307.                     GetColorPixel := longPtr(thePixel)^;
  308.                 end;
  309.         end;    {case depth of}
  310.     end;    {function GetColorPixel}
  311.  
  312.  
  313.     function MyGetPixel (pixelNum: longint): PixelRec;
  314. {Get the value of the pixelNum pixel on the screen.}
  315.         var
  316.             x, y: integer;
  317.             memValue: longint;
  318.             cPix: RGBColor;
  319.             HSLPix: HSLColor;
  320.     begin
  321.         pixelNum := pixelNum - 1;
  322.         y := ScreenTop + (pixelNum div ScreenWidth);
  323.         x := ScreenLeft + (pixelNum mod ScreenWidth);
  324.         case pixMethod of
  325.             DirectMono: 
  326.                 MyGetPixel.sortValue := GetBWPixel(x, y, drawBitMap);        {In BW the memoryValue is unused.}
  327.             MonoQuickDraw: 
  328.                 if GetPixel(x, y) then
  329.                     MyGetPixel.sortValue := 1
  330.                 else
  331.                     MyGetPixel.sortValue := 0;
  332.  
  333.             DirectColor, Direct32Bit, ColorQuickDraw: 
  334.                 begin
  335.                     if pixMethod = ColorQuickDraw then
  336.                         begin
  337.                             GetCPixel(x, y, cPix);
  338.                             FourBytes(memValue)[2] := SixBytes(cPix)[1];    {Red}
  339.                             FourBytes(memValue)[3] := SixBytes(cPix)[3];    {Green}
  340.                             FourBytes(memValue)[4] := SixBytes(cPix)[5];    {Blue}
  341.                         end
  342.                     else
  343.                         begin    {Direct pixel access}
  344.                             memValue := GetColorPixel(x, y);
  345.                             case ScreenDepth of
  346.                                 1, 2, 4, 8: 
  347.                                     Index2Color(memValue, cPix);
  348.                                 16: 
  349. {$R-}
  350.                                     begin    {memValue is 0rrr rrgg gggb bbbb bitwise}
  351.                                         cPix.red := BSL(BitAnd(memValue, $7C00), 1);
  352.                                         cPix.green := BSL(BitAnd(memValue, $03E0), 6);
  353.                                         cPix.blue := BSL(BitAnd(memValue, $001F), 11);
  354.                                     end;
  355. {$R+}
  356.                                 32:     {MemValue is 00rr ggbb, four bytes}
  357.                                     begin
  358.                                         cPix.red := FourBytes(memValue)[2];
  359.                                         cPix.green := FourBytes(memValue)[3];
  360.                                         cPix.blue := FourBytes(memValue)[4];
  361.                                     end;
  362.                             end;    {case ScreenDepth}
  363.                         end;    {Direct pixel access}
  364.  
  365. {Figure out the HSL version of the pixel and use that to get the sortValue}
  366.                     RGB2HSL(cPix, HSLPix);        {Convert to HSL}
  367.                     MyGetPixel.memoryValue := memValue;
  368.                     FourBytes(MyGetPixel.sortValue)[2] := SixBytes(HSLPix)[1];    {Hue}
  369.                     FourBytes(MyGetPixel.sortValue)[3] := SixBytes(HSLPix)[5];    {Saturation}
  370.                     FourBytes(MyGetPixel.sortValue)[4] := SixBytes(HSLPix)[3];    {Lightness}
  371.                 end;    {pixMethod one of the color ones}
  372.         end;    {case pixMethod}
  373.     end;    {procedure MyGetPixel}
  374.  
  375.  
  376.  
  377.  
  378.     procedure SwapPixels (first, second: longint);
  379. {Swap the pixels in positions first and second}
  380.         var
  381.             value1, value2: pixelRec;
  382.     begin
  383.         value1 := MyGetPixel(first);
  384.         value2 := MyGetPixel(second);
  385.         MySetPixel(first, value2);
  386.         MySetPixel(second, value1);
  387.     end;    {procedure SwapPixels}
  388.  
  389.  
  390.  
  391.     procedure SortPair (first, second: longint);
  392. {Sort the pair of pixels at positions first and second so the pixel at first is less.}
  393.         var
  394.             value1, value2: pixelRec;
  395.     begin
  396.         value1 := MyGetPixel(first);
  397.         value2 := MyGetPixel(second);
  398.         if value1.sortValue > value2.sortValue then
  399.             begin    {swap them}
  400.                 MySetPixel(first, value2);
  401.                 MySetPixel(second, value1);
  402.             end;
  403.     end;    {procedure SortPair}
  404.  
  405.     procedure SortThree (first, second, third: longint);
  406. {Sort the three pixels at first, second, and third, with first being the least.}
  407.         var
  408.             firstPixel, secondPixel, thirdPixel, tempPixel: pixelRec;
  409.     begin
  410.         firstPixel := MyGetPixel(first);
  411.         secondPixel := MyGetPixel(second);
  412.         thirdPixel := MyGetPixel(third);
  413.         if firstPixel.sortValue > secondPixel.sortValue then
  414.             begin
  415.                 tempPixel := firstPixel;
  416.                 firstPixel := secondPixel;
  417.                 secondPixel := tempPixel;
  418.             end;
  419. {now first < second; third is unknown. That leaves 3 possible orderings: 123, 132, 312.}
  420.         if secondPixel.sortValue < thirdPixel.sortValue then
  421.             begin    {know order is 123}
  422.                 MySetPixel(first, firstPixel);
  423.                 MySetPixel(second, secondPixel);
  424.             end    {And the third is already correct.}
  425.         else    {order is 132 or 312}
  426.             if firstPixel.sortValue < thirdPixel.sortValue then
  427.                 begin    {132}
  428.                     MySetPixel(first, firstPixel);
  429.                     MySetPixel(second, thirdPixel);
  430.                     MySetPixel(third, secondPixel);
  431.                 end    {132 order}
  432.             else    {order is 312}
  433.                 begin
  434.                     MySetPixel(first, thirdPixel);
  435.                     MySetPixel(second, firstPixel);
  436.                     MySetPixel(third, secondPixel);
  437.                 end;    {312 order}
  438.     end;    {procedure SortThree}
  439.  
  440.  
  441.     procedure MySetPixel (pixelNum: longint;
  442.                                     pixelValue: pixelRec);
  443. {Set the pixel at pixelNum to value.}
  444.         var
  445.             x, y: integer;
  446.             cPix: RGBColor;
  447.     begin
  448.         pixelNum := pixelNum - 1;
  449.         y := ScreenTop + (pixelNum div ScreenWidth);
  450.         x := ScreenLeft + (pixelNum mod ScreenWidth);
  451.         case pixMethod of
  452.             DirectMono: 
  453.                 SetBWPixel(x, y, pixelValue.sortValue, drawBitMap);        {In BW the memoryValue is unused.}
  454.             MonoQuickDraw: 
  455.                 begin
  456.                     if PixelValue.sortValue = 1 then
  457.                         PenMode(patCopy)
  458.                     else
  459.                         PenMode(notPatCopy);
  460.                     MoveTo(x, y);
  461.                     Line(0, 0);
  462.                 end;
  463.             DirectColor, Direct32Bit: 
  464.                 SetColorPixel(x, y, pixelValue.memoryValue);
  465.             ColorQuickDraw: 
  466.                 begin
  467.                     SixBytes(cPix)[1] := FourBytes(pixelValue.memoryValue)[2];    {Red}
  468.                     SixBytes(cPix)[3] := FourBytes(pixelValue.memoryValue)[3];    {Green}
  469.                     SixBytes(cPix)[5] := FourBytes(pixelValue.memoryValue)[4];    {Blue}
  470.                     SetCPixel(x, y, cPix);
  471. {•     RGBForeColor(cPix);•}
  472. {•     MoveTo(x, y);•}
  473. {•     Line(0, 0);            {Faster than SetCPixel, I think. I timed it but forgot.•]}
  474.                 end;
  475.         end;    {case}
  476.     end;    {procedure MySetPixel}
  477.  
  478.  
  479.  
  480.  
  481.     procedure RandomBWFill (drawBitMap: BitMap);
  482. {Fill the screen (assumed to be monochrome) randomly.}
  483.         var
  484.             i: integer;
  485.             b: bitMap;
  486.             destRect: Rect;
  487.             WordNum: integer;
  488.             pt: wordPtr;
  489.     begin
  490.         b.baseAddr := NewPtr(256);
  491.         b.rowBytes := 256;
  492.         SetRect(b.bounds, 0, 0, ScreenWidth, 1);
  493.  
  494.         for i := 0 to ScreenHeight do
  495.             begin
  496.                 SetRect(destRect, 0, i, ScreenWidth, i + 1);
  497.                 for WordNum := 0 to 32 do
  498.                     begin
  499.                         pt := WordPtr(ord4(b.baseAddr) + 2 * WordNum);
  500.                         pt^ := random;
  501.                     end;
  502.                 CopyBits(b, drawBitMap, b.bounds, destRect, srcCopy, nil);
  503.             end;
  504.         DisposPtr(b.baseAddr);
  505.     end;    {procedure RandomBWFill}
  506.  
  507.  
  508.     procedure RandomColorFill (drawPixMap: pixMapHandle);
  509. {Fill the screen randomly (assuming color Quickdraw)}
  510.         var
  511.             myPMap: PixMapHandle;
  512.             rBytes, rWords, ignore, i, j: integer;
  513.             myBase: wordPtr;
  514.             destRect: Rect;
  515.     begin
  516.         myPMap := NewPixMap;
  517.         CopyPixMap(drawPixMap, myPMap);
  518.         rBytes := BAND(myPMap^^.rowBytes, $1FFF) + 4;    {Strip flags, and be sure}
  519.         rWords := rBytes div 2;                {the last word won’t overflow}
  520.         myPMap^^.baseAddr := NewPtr(rBytes);
  521.         SetRect(myPMap^^.bounds, 0, 0, ScreenWidth, 1);
  522. {Now randomize my PixMap and copyBits stuff in place}
  523.  
  524.         for j := 0 to ScreenHeight do
  525.             begin
  526.                 myBase := wordPtr(myPmap^^.baseAddr);
  527.                 SetRect(destRect, 0, j, ScreenWidth, j + 1);
  528.                 for i := 1 to rWords do
  529.                     begin
  530.                         myBase^ := random;
  531.                         myBase := wordPtr(ord(myBase) + 2);
  532.                     end;
  533.                 CopyBits(BitMapPtr(myPMap^)^, BitMapPtr(drawPixMap^)^, myPMap^^.bounds, destRect, srcCopy, nil);
  534.             end;
  535.         DisposPtr(myPMap^^.baseAddr);
  536.         DisposPixMap(myPMap);
  537.     end;    {procedure RandomColorFill}
  538.  
  539.  
  540.     procedure RandomFillScreen;
  541. {Randomly fill the screen. Assumes that LockForDrawing has been called.}
  542.  
  543.     begin
  544.         case pixMethod of
  545.             DirectMono, MonoQuickDraw: 
  546.                 RandomBWFill(drawBitMap);
  547.             DirectColor, Direct32Bit, ColorQuickDraw: 
  548.                 RandomColorFill(drawPixMap);
  549.         end;
  550.     end;
  551.  
  552.  
  553. end.